package 寒假刷题;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;

public class 山羊拉丁文 {
    public String toGoatLatin(String sentence) {
        ArrayList<Character> list = new ArrayList<>();
        Collections.addAll(list,'a','e','i','o','u','A','E','I','O','U');
        StringBuilder builders = new StringBuilder();
        String[] words = sentence.split(" ");
        for (int i = 0; i < words.length; i++) {
            StringBuilder builder = new StringBuilder();
            char c = words[i].charAt(0);
            if (list.contains(c)){
                builder.append(words[i]).append("ma");
            }
            else{
                String substring = words[i].substring(1, words[i].length());
                builder.append(substring).append(c).append("ma");
            }
            for (int j = 0; j < i+1; j++) {
                builder.append("a");
            }
            builders.append(builder).append(" ");
        }
        return builders.toString().trim();
    }

}
